package br.furb.view.components;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;

import br.furb.model.negocio.Financeiro;

public class FinanceiroPanel extends JPanel {
	
	private JPanel panel_1;
	private JPanel panel;
	private JTextField textField;
	private Financeiro financeiro;
	private JLabel label;
	private JLabel label_1;

	/**
	 * Create the panel.
	 */
	public FinanceiroPanel(JFrame owner) {
		setLayout(new BorderLayout(0, 0));
		
		panel = new JPanel();
		add(panel, BorderLayout.NORTH);
		
		JLabel lblFinanceiro = new JLabel("Financeiro");
		lblFinanceiro.setFont(new Font("Tahoma", Font.BOLD, 20));
		panel.add(lblFinanceiro);
		
		panel_1 = new JPanel();
		add(panel_1, BorderLayout.CENTER);
		
		JLabel lblCaixa = new JLabel("Caixa:");
		lblCaixa.setFont(new Font("Tahoma", Font.BOLD, 12));
		
		textField = new JTextField();
		textField.setColumns(10);
		
		JLabel lblTotalDespezas = new JLabel("Total Despezas:");
		lblTotalDespezas.setFont(new Font("Tahoma", Font.BOLD, 12));
		
		JLabel lblValoresAReceber = new JLabel("Valores a Receber:");
		lblValoresAReceber.setFont(new Font("Tahoma", Font.BOLD, 12));
		
		label = new JLabel("");
		
		label_1 = new JLabel("");
		GroupLayout gl_panel_1 = new GroupLayout(panel_1);
		gl_panel_1.setHorizontalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(lblCaixa)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(lblTotalDespezas)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(label))
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(lblValoresAReceber)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(label_1)))
					.addContainerGap(272, Short.MAX_VALUE))
		);
		gl_panel_1.setVerticalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblCaixa)
						.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblTotalDespezas)
						.addComponent(label))
					.addGap(18)
					.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblValoresAReceber)
						.addComponent(label_1))
					.addContainerGap(169, Short.MAX_VALUE))
		);
		panel_1.setLayout(gl_panel_1);
		
		financeiro = new Financeiro();
	}
	
	public Financeiro getFinancas() {
		financeiro.setCaixa(Double.parseDouble("0" + textField.getText()));
		return financeiro;
	}
	
	public void setFinancas(Financeiro f) {
		this.financeiro = f;

		textField.setText("" + f.getCaixa());
		label.setText("" + f.getDespesas());
		label_1.setText("" + f.getValoresAReceber());
	}
	
	public void AtualizaFinancas() {
		textField.setText("" + financeiro.getCaixa());
		label.setText("" + financeiro.getDespesas());
		label_1.setText("" + financeiro.getValoresAReceber());
	}
}